An image processing apparatus has been known which acquires image data by reading a document and detects a document region from the image data. For example, the image processing apparatus acquires an image containing a document region, detects coordinate values of edge candidate pixels based on the obtained image, calculates the tilting of the document region based on the detected coordinate values of the edge candidate pixels, and extracts coordinate values of edge end candidate pixels based on the detected coordinate values of the edge candidate pixels. Then, the image processing apparatus calculates a straight line corresponding to an edge based on the calculated tilting of the document region and the extracted coordinate values of edge end candidate pixels, and corrects the tilting of the document region on the basis of the calculated straight line corresponding to the edge, and crops the document region from the image based on the relevant straight line.
Related art is disclosed in Japanese Laid-open Patent Publication No. 2009-218953.